[AArch64][GlobalISel] Legalize s16 G_FCONSTANT to avoid widening to G_CONSTANT#161205
Merged
davemgreen merged 4 commits intollvm:mainfrom Oct 8, 2025
Merged
[AArch64][GlobalISel] Legalize s16 G_FCONSTANT to avoid widening to G_CONSTANT#161205davemgreen merged 4 commits intollvm:mainfrom
davemgreen merged 4 commits intollvm:mainfrom
Conversation
Member
|
@llvm/pr-subscribers-llvm-globalisel @llvm/pr-subscribers-backend-aarch64 Author: Ryan Cowan (HolyMolyCowMan) ChangesWhen widening a This PR legalizes Full diff: https://github.com/llvm/llvm-project/pull/161205.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index 7ee54c5932b15..1593f32d1fc6c 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -678,8 +678,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
.widenScalarToNextPow2(0)
.clampScalar(0, s8, s64);
getActionDefinitionsBuilder(G_FCONSTANT)
- .legalFor({s32, s64, s128})
- .legalFor(HasFP16, {s16})
+ // Always legalize s16 to prevent G_FCONSTANT being widened to G_CONSTANT
+ .legalFor({s16, s32, s64, s128})
.clampScalar(0, MinFPScalar, s128);
// FIXME: fix moreElementsToNextPow2
|
davemgreen
reviewed
Sep 29, 2025
Contributor
|
Yeah this needs to address the regbank regressions. |
aemerson
approved these changes
Oct 6, 2025
Contributor
Author
|
By moving the |
svkeerthy
pushed a commit
that referenced
this pull request
Oct 9, 2025
…_CONSTANT (#161205) When widening a `G_FCONSTANT` it is converted to a `G_CONSTANT` to avoid loss in accuracy (see #56454). This means that some folds such as `G_FPEXT(G_FCONSTANT)` fail to work when the scalar has been widened. This PR legalizes `s16`s by default in line with how s16 `G_CONSTANT`s are treated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When widening a
G_FCONSTANTit is converted to aG_CONSTANTto avoid loss in accuracy (see #56454). This means that some folds such asG_FPEXT(G_FCONSTANT)fail to work when the scalar has been widened.This PR legalizes
s16s by default in line with how s16G_CONSTANTs are treated.